jextract/jni: Support optional tuple return values#720
Closed
sidepelican wants to merge 6 commits intoswiftlang:mainfrom
Closed
jextract/jni: Support optional tuple return values#720sidepelican wants to merge 6 commits intoswiftlang:mainfrom
sidepelican wants to merge 6 commits intoswiftlang:mainfrom
Conversation
Contributor
Author
|
I understand the hesitation to merge this PR due to the workaround included. |
This was referenced Apr 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, code generation is skipped when an optional tuple is used as a return value.
This PR fixes this.
Support for optional tuples as parameters is currently out of scope.
Given the difficulty, I've decided to postpone this to a subsequent PR.
Architectural Concerns & Refactoring
During the implementation, I encountered a bottleneck where
JNISwift2JavaGenerator+JavaTranslation.swiftneeded to reference results fromJNISwift2JavaGenerator+NativeTranslation.swift.The current architecture handles Java-side and Swift-side glue code generation independently.
This separation makes it increasingly difficult to keep the generation strategies in sync and ensure consistency between the two sides.
Future Work & Current Workaround
I believe unifying these generation logics will be essential in the future.
However, given the current scale of the implementation, such a major refactoring is extremely difficult at this stage.
As a result, this PR addresses the immediate issue using a workaround to bypass these structural limitations for now, while acknowledging the underlying architectural debt.